/*
 * @lc app=leetcode id=26 lang=cpp
 *
 * [26] Remove Duplicates from Sorted Array
 */
class Solution {
public:
    int removeDuplicates(vector<int>& nums) {

        int len = nums.size();
        if (len < 1) {
            return 0;
        }

        int cnt = 1;
        int pos = 1;
        int last = nums[0];
        for (int i=1; i<len; i++) {
            if (last != nums[i]) {
                last = nums[i];
                nums[pos++] = last;
                cnt++;
            }
        }
        
        return cnt;
    }
};

